#include<bits/stdc++.h>

using pii = std::pair<int, int>;
using i64 = long long;
using u64 = unsigned long long;

#define for_range(i, l, r) for(int i = (l); i < (r); i++)
#define rfor_range(i, l, r) for(int i = (r)-1; i >= (l); i--)
#define for_each(i, l, r) for(int i = (l); i <= (r); i++)
#define rfor_each(i, l, r) for(int i = (r); i >= (l); i--)

#define chmin(a, b) a = std::min(a, (b))
#define chmax(a, b) a = std::max(a, (b))
#define all(a) a.begin(), a.end()

#define ll first
#define rr second

void solve(){
    //input
    int CAR, CHECK, len, limit;
    std::cin >> CAR >> CHECK >> len >> limit;

    std::vector<int> x(CAR), v(CAR), a(CAR);
    for_range(i, 0, CAR){
        std::cin >> x[i] >> v[i] >> a[i];
    }
    std::vector<int> check(CHECK);
    for_range(i, 0, CHECK){
        std::cin >> check[i];
    }
    std::sort(all(check));
    //sugs
    std::vector<pii> sugs;
    for_range(i, 0, CAR){
        auto danger = [&](int pos) -> bool{
            return 1ll * v[i] * v[i] + 2 * a[i] * (pos - x[i]) > 1ll * limit * limit;
        };

        int fst = int(std::lower_bound(all(check), x[i]) - check.begin());
        if(a[i] >= 0){//SAFE(CHECK) DANGER(Y)
            int L = fst - 1, R = CHECK;
            while(L + 1 < R){
                int mid = (L + R) / 2;
                if(danger(check[mid])){
                    R = mid;
                } else{
                    L = mid;
                }
            }
            if(R < CHECK){
                sugs.push_back(std::make_pair(R, CHECK-1));
            }
        }
        else{//a[i] < 0//DANGER(Y) SAFE(CHECK)
            int L = fst - 1, R = CHECK;
            while(L + 1 < R){
                int mid = (L + R) / 2;
                if(danger(check[mid])){
                    L = mid;
                } else{
                    R = mid;
                }
            }
            // std::cerr << i << " " << fst << " " << L << "\n";
            if(L >= fst){
                sugs.push_back(std::make_pair(fst, L));                            
            }
        }
    }

    std::cout << sugs.size() << " ";

    //tanxin
    //init data
    std::sort(all(sugs), [&](pii s0, pii s1){
        return s0.ll != s1.ll ? s0.ll < s1.ll : s0.rr > s1.rr;
    });//front is not in next
    std::vector<pii> tmp;
    for(pii p_sugs : sugs){
        int r = p_sugs.second;
        while(!tmp.empty() && r <= tmp.back().rr){
            tmp.pop_back();
        }
        if(tmp.empty() || tmp.back().rr < r){
            tmp.push_back(p_sugs);
        }
    }

    sugs = tmp;
    //main
    int ans = 0;
    int lst = -1;
    for(pii p_sugs : sugs){
        int l = p_sugs.ll, r = p_sugs.rr;
        if(l > lst){
            lst = r;
            ans++;
        }
    }
    //output
    std::cout << CHECK - ans << "\n";
}

int main(){
    assert(freopen("detect.in", "r", stdin));
    assert(freopen("detect.out", "w", stdout));

    std::cin.tie(0);
    std::ios::sync_with_stdio(0);

    int T = 1;
    std::cin >> T;
    for_range(t, 0, T){
        solve();
    }
    return 0;
}
// g++ detect.cpp -O2 -Wall -Wextra -Wshadow -Wconversion -fsanitize=undefined -fsanitize=address -D__GLIBCXX_DEBUG -o detect
// /usr/bin/time